package org.scboy.common.dynamic.node.httpNode;

import org.scboy.common.annotation.ScriptNode;
import org.scboy.common.dynamic.node.BaseNode;
import org.scboy.utils.entitys.coobi.Model;

import cn.hutool.json.JSONObject;

@ScriptNode(value="HTTP_REQUEST",start=true)
public class HttpRequestNode extends BaseNode {

	@Override
	public void create(JSONObject object) {
		
	}

	@Override
	public Object run() {
		/**
		 * 测试日志
		 */
		if(this.script.isTest()) {
			this.script.appendMsg("----->开始执行："+getNodeName()+" 节点ID："+this.getId());
		}
		
		/**
		 * 流出节点
		 */
		BaseNode runTo = getRunTo("to");
		
		Model _params=(Model)getData("params");
		Model body=_params.getModel("body");
		Model header=_params.getModel("header");
		Model params=_params.getModel("params");

		this.setData("body", body);
		this.setData("header", header);
		this.setData("params", params);
		/**
		 * 测试日志
		 */
		if(this.script.isTest()) {
			this.script.appendMsg("缓存数据：\r\n"+entityToString(this.getDataAll()));
			this.script.appendMsg("执行下个节点："+runTo.getNodeName()+" 节点ID："+runTo.getId());
		}
		return runTo.run();
	}
}
